import copy


class Solution:
    def __init__(self):
        self.list_coin = {}
    
    def add_list_coin(self, value):
        if not self.list_coin.get(value):
            self.list_coin[value] = 1
        else:
            self.list_coin[value] += 1
    
    def coinChangeCore(self, coins, amount, coins_num, list_num, coins_dict):
        if amount == 0:
            if list_num[0] > coins_num:
                list_num[0] = coins_num
            self.list_coin = coins_dict
            return True
        elif amount < 0:
            return False
        elif len(coins) == 0:
            return False
        num = amount // coins[-1] + 1
        for i in range(num)[::-1]:
            remainder = amount - coins[-1] * i
            if coins_num + i >= list_num[0]:
                return
            coins_dict[coins[-1]] = i
            self.coinChangeCore(coins[:-1], remainder, coins_num + i, list_num, copy.copy(coins_dict))
    
    def coinChange(self, coins, amount):
        """
        :type coins: List[int]
        :type amount: int
        :rtype: int
        """
        remainder = amount - amount // coins[-1] * coins[-1]
        list_num = [21473648]
        coins.sort()
        self.coinChangeCore(coins, amount, 0, list_num, {})
        if list_num[0] != 21473648:
            return list_num[0]
        else:
            return -1


if __name__ == '__main__':
    m, n = [int(value) for value in input().split(" ")]
    coins = []
    for i in range(n):
        coins.append(int(input()))
    sol = Solution()
    results = {}
    for i in range(1, m+1):
        result = sol.coinChange(coins, amount=i)
        if result == -1:
            print(-1)
        for coin, num in sol.list_coin.items():
            print(sol.list_coin)
            if results.get(coin) is None:
                results[coin] = num
            else:
                if results[coin] < num:
                    results[coin] = num

    result = 0
    for k,v in results.items():
        result+=v
    print("="*50)
    print(results)
    print(result)
